<include file="header" />
<div class="wraper normal" js="wapjs/meeting/js/meetinginvite">
	<div class="head clearfix">
		<if condition="$one['status'] eq 10">
			<a href="{BEESCRM::U('/Meeting/MeetingPersonal/index',array('type' => 3,'account_id'=>$accountId))}" class="iconfont icon-zuo"></a>
			<else />
			<a href="{BEESCRM::U('/meeting/meeting/ucenter',array('audited' => 1,'account_id'=>$accountId))}" class="iconfont icon-zuo"></a>
		</if>
		<span class="head-name">填写基本信息</span>
		<input type="hidden" id="js_account_id" value="{BEESCRM:$accountId}">
	</div>

	<include file="statusbox"/>

	<div class="form-box">
		<p class="form-list">直邀会议</p>
		<form>
			<p class="form-list"><input placeholder="请输入会议名称" name="title" value="{BEESCRM:$one.title}" /></p>
			<p class="form-list"><input placeholder="请输入开始时间" name="start_time" id="start_time" value="{BEESCRM:$one.start_time}" /></p>
			<p class="form-list"><input placeholder="请输入结束时间" name="end_time" id="end_time" value="{BEESCRM:$one.end_time}" /></p>
			<if condition="$one['department_path']">
				<p class="form-list">
					<a href="{BEESCRM::U('/Meeting/InviteUser/firstDepartment',array('account_id' => $accountId))}" class="list-line text-green">
						{BEESCRM:$one['department_path']}<if condition="$one['department_path']"> > </if>{BEESCRM:$one['real_name']}
					</a>
					<input type="hidden" name="department_id" value="{BEESCRM:$one['department_id']}" />
					<input type="hidden" name="organizer" id="organizer" value="{BEESCRM:$one['user_id']}" />
				</p>
			<else/>			
				<p class="form-list">
					<a url="/Meeting/InviteUser/firstdepartment" id="jump" class="list-line text-green">
						<span class="iconfont icon-tianjia"></span> 选择会议联系人
					</a>
				</p>
			</if>
			<p class="form-list"><input placeholder="请输入联系人电话" name="mobile" value="{BEESCRM:$one.mobile}" /></p>
		</form>
	</div>
	<div class="btn-box clearfix">
		<a href="javascript:void(0);" data-draft="1" class="btn half-btn bg-white">保存草稿</a>
		<a href="javascript:void(0);" data-draft="0" class="btn half-btn bg-green">下一步</a>
	</div>
</div>

<script type="text/javascript" src="/assets/public/seajs/sea.js"></script>
<script enter="publicjs/public" id="confnode" async="async" src="/assets/public/config.js"></script>
<script type="text/javascript" src="/assets/public/jquery-2.1.0.min.js"></script>

<script>
		$('.bg-green, .bg-white').click(function(){ //下一步
			if(!$("input[name='title']").val()) {
				fm.alert('请输入会议名称~');return false;
			}
			//获取时间戳（单位秒）
			var start_timestamp = Date.parse(new Date($("input[name='start_time']").val())) / 1000;
			var end_timestamp = Date.parse(new Date($("input[name='end_time']").val())) / 1000;
			var current_timestatmp = Date.parse(new Date()) / 1000;
 			if(!$("input[name='start_time']").val()) {
				fm.alert('请选择会议开始时间~');return false;
			}
			if(!$("input[name='end_time']").val()){
				fm.alert('请选择会议结束时间~');return false;
			}
			if (start_timestamp < current_timestatmp){
				fm.alert('会议的开始时间要大于当前时间~');return false;
			}
			if(start_timestamp >= end_timestamp){
				fm.alert('会议的开始时间不能大于或等于结束时间');return false;
			}
			if($("input[name='start_time']").val() > $("input[name='end_time']").val()){
				fm.alert('开始时间不能大于结束时间');
				return false;
			}
			if($("input[name='start_time']").val() == $("input[name='end_time']").val()){
				fm.alert('开始时间不能等于结束时间');
				return false;
			}
			if(!$("#organizer").val()) {
				fm.alert('请选择联系人~');return false;
			}
			if(!$("input[name='mobile']").val()) {
				fm.alert('请输入联系电话~');return false;
			}

			var phone = $("input[name='mobile']").val();
			if(phone){
				var myreg = /^1[34578]\d{9}$/;
				if(!myreg.test(phone)) {
					fm.alert('请输入有效的联系电话！');
					return false;
				}
			}

			var data = $('form').serialize();
			var is_draft = $(this).attr('data-draft');
			var accountId = $('#js_account_id').val();

			data += "&is_draft=" + is_draft;
			var url = '/Meeting/MeetingInvite/saveStep/step/one/account_id/' + accountId;
			$.ajax({
				url:url,
				data:data,
				type:'post',
				success:function(result){
					if(result){
						if(is_draft == 1){
							location.href = "/Meeting/MeetingPersonal/index/type/3/account_id/" + accountId;
						}else{
							location.href = "/Meeting/MeetingInvite/addInviteMeeting/step/two/account_id/" + accountId;
						}
					}
				}
			});
		});

</script>
<include file="footer" />